@extends('layouts.back_stage')
@section('style')
    @parent
    <style>
        .address {
            border-color: #cfdadd;
            border-radius: 2px;
            width: 25%;
            height: 30px;
            padding: 6px 10px;
            font-size: 12px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #cfdadd;
            box-shadow: none;
            -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        }
        .hide_div{margin:20px 0;width:100%;float:left;display:none;}
        .virtual_inp{width:180px;float:left;}
        .virtualPeople{width:355px;height:100px;overflow-y:auto;overflow-x:hidden;border:1px solid #ccc;margin-bottom:0;float:right}
        .virtualPeople li{width:100%;height:25px;line-height:25px;padding:0 10px;white-space:nowrap;overflow:hidden;text-overflow: ellipsis;}
        .virtualPeople li:hover{background:#f1f1f1;color:#383838;}
    </style>
@endsection
@section('content')
    <script>
        var areas = [
                @foreach($areas as $v)
                    ['{{ $v->area_name }}','{{ $v->area_bh }}'],
            @endforeach
            ];
        // 省
        function getprovince() {
            var option = '';
            for( var i = 0;i< areas.length; i++)
            {
                if(areas[i][1].substr(-4) == '0000')
                {
                    option += "<option value="+areas[i][1]+">"+areas[i][0]+"</option>"
                }
            }
            return option;
        }
        //市
        function getcity(sign) {
            var option = '';
            for( var i = 0;i< areas.length; i++){

                if(areas[i][1].substr(-2) == '00' && areas[i][1].substr(0,2) == sign.substr(0,2) && areas[i][1].substr(-4) != '0000')
                {
                    option += "<option value="+areas[i][1]+">"+areas[i][0]+"</option>"
                }
            }
            return option;
        }
        //区
        function getcity1(sign) {
            var option = '';
            for( var i = 0;i< areas.length; i++){
                if( areas[i][1].substr(-2) != '00' && areas[i][1].substr(0,4) == sign.substr(0,4) ){
                    option += "<option value="+areas[i][1]+">"+areas[i][0]+"</option>"
                }
            }
            return option;
        }
    </script>
    <div class="container">
        <div style="padding:20px 0;"><h3>客户列表</h3></div>
        <div class="pull-left" style="width: 100%;margin-bottom: 20px">
            <form action="/backstage/" role="form" style="display: inline-block;margin-right: 10px">
                <label>用户类型：</label>
                <select name="type" class="address" id="sort" class="type" style="width: 150px;">
                    @if(isset($_GET['type']) && $_GET['type'] == 0 && $_GET['type'] != "")
                        <option value="0" >普通用户</option>
                        <option value="" >请选择</option>
                        <option value="1">销售</option>
                    @elseif(isset($_GET['type']) && $_GET['type'] == 1)
                        <option value="1">销售</option>
                        <option value="" >请选择</option>
                        <option value="0" >普通用户</option>
                    @else
                        <option value="" >请选择</option>
                        <option value="0" >普通用户</option>
                        <option value="1">销售</option>
                    @endif
                </select>
                @if($self_company_id == 1)
                    <label>选择公司：</label>
                    <select name="company_id" id="sort" class="address" style="width: 150px">
                        @if(isset($_GET['company_id']) && $_GET['company_id'])
                            <option value="{{$_GET['company_id']}}" selected>{{ $company_name[$_GET['company_id']]}}</option>
                        @endif
                        <option value="">全部公司</option>
                        @foreach($company_name as $k=>$v)
                            <option value="{{ $k }}">{{ $v }}</option>
                        @endforeach
                    </select>
                @else
                    <input type="hidden" name="company_id" value="{{ $self_company_id }}">
                @endif
                <label>用户姓名:</label>
                <input class="address" style="width: 150px" type="text" name="user_name" placeholder="输入用户姓名" value="">
                <label>手机号码:</label>
                <input class="address" style="width: 150px" type="text" name="user_tel" placeholder="手机号码" value="">
                <label>微信号:</label>
                <input class="address" style="width: 150px" type="text" name="user_vx" placeholder="微信号" value="">
                <label>是否VIP：</label>
                <select id="member" class="address" style="width:80px" name="pass">
                    @if($pass !=null && $pass != '')
                        @if($pass == 1)
                             <option value="1">是</option>
                            @else
                            <option value="0">否</option>
                        @endif
                    @endif
                    <option value="">请选择</option>
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
                <button type="submit" class="btn btn-info" id="sort_btn" style="margin-bottom: 5px;">搜索</button>
            </form>
            <a class="btn btn-primary" style="float:right;margin-right:30px" data-toggle="modal" data-target="#myModal">添加用户</a>
        </div>
        <span style="display:none;" class="info_sum">{{$whiteUser_count}}</span>
        <table class="table">
            <thead>
            <tr>
                <th>用户姓名</th>
                <th>VIP</th>
                <th>手机号</th>
                <th>微信号</th>
                <th>用户类型</th>
                <th>所属公司</th>
                <th>区域</th>
                <th>虚拟区</th>
                <th>备注</th>
                <th>&nbsp;&nbsp;&nbsp;操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach($datas as $whiteUser)
                <tr id="delete_{{$whiteUser->id}}">
                    <td> {{ $whiteUser->username }}</td>
                    <td>
                        @if($whiteUser->is_bus == 0)
                        @if($whiteUser->pass)
                            <input type="checkbox" disabled checked>
                            @else
                            <input type="checkbox" disabled>
                        @endif
                            @endif
                    </td>
                    <td> {{ $whiteUser->user_tel }}</td>
                    <td>{{ $whiteUser->wechat_code }}</td>
                    @if($whiteUser->is_bus==0)
                        <td> 普通客户</td>
                    @elseif($whiteUser->is_bus==1)
                        <td>销售</td>
                    @elseif($whiteUser->is_bus==2)
                        <td>仓库收货人员</td>
                    @endif
                    <td> {{ $companys[$whiteUser->company_id] }}</td>
                    <td> {{ $whiteUser->user_area.$whiteUser->area_detail }}</td>
                    @if($whiteUser->area_id == 0)
                        <td style="color: #ccc;"> 尚未分配 </td>
                    @else
                        <td>{{ $virtual[$whiteUser->area_id] }}</td>
                    @endif
                    <td>{{ $whiteUser->describe }}</td>
                    <td>
                        <a href="/backstage/edit?id={{ $whiteUser->id }}" >编辑</a>
                        <a href="javascript:;" onclick="deleteUser({{ $whiteUser->id }})" >删除</a>
                        <a href="javascript:;" onclick="moveToBlack({{ $whiteUser->id }})" id="delete">拉黑</a>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        <div style="float: right"><div style="float: right;margin:20px 0;"><button class="btn btn-info" onclick="turnPage1()" style="float:right;">跳转</button><input type="text" class="form-control turnPage1" style="width:6rem;float: right;margin:0 5px;"></div>{{ $datas->appends(['sort'=>$sort,'type'=>$type,'company_id'=>$company_id,'user_name'=>$user_name,'pass'=>$pass])->links() }}</div>

        <!-- 模态框（Modal） -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel">
                            添加用户
                        </h4>
                    </div>
                    <div class="modal-body">
                        <div class="container" style="width:100%;">
                            <div class="row">
                                <div style="margin: 20px;">
                                    <h3>添加用户</h3>
                                </div>
                                <div style="width:100%">
                                    @if(Auth::guard('admin')->user()->company_id == 1)
                                        <select id="type" class="address client">
                                            <option value="0">普通客户</option>
                                            <option value="1">销售</option>
                                        </select>
                                        <select id="company_id" class="address comp company_sel">
                                            <option value="">请选择</option>
                                            @foreach($company_name as $key => $value)
                                                <option value="{{$key}}">{{$value}}</option>
                                            @endforeach
                                        </select>
                                        <div class="brand_box" style="display: none;margin-top:20px;">
                                            @foreach($company_brand_list as $key => $value)
                                                <label class="checkbox-inline">
                                                    <input type="checkbox" name="brand" class="choose_inp" value="{{$key}}">{{$value}}
                                                </label>
                                            @endforeach
                                        </div>
                                        <input type="hidden" id="brand_ids" value="-1">
                                    @else
                                        <input type="hidden" id="type" value="0">
                                        <input type="hidden" class="comp" id="company_id" value="{{ $self_company_id }}">
                                        <input type="hidden" id="brand_ids" value="-1">
                                    @endif
                                    <input class="form-control" style="margin-bottom: 20px;margin-top: 20px; width: 300px" type="text" placeholder="用户姓名(最长6个字符)" maxlength="6" name="username" id="username">
                                    <input class="form-control" style="margin-bottom: 20px;width: 300px" type="text" placeholder="手机号码" maxlength="11" name="user_tel" id="user-tel" checked>
                                    <input class="form-control" style="margin-bottom: 20px;width: 300px" type="text" placeholder="微信号" name="user_vx" id="user-vx" checked>
                                    <div class="sale_div">
                                        <div>
                                            <select class="address Prov">
                                                <option value="">省</option>
                                                <script>document.write(getprovince());</script>
                                            </select>
                                            <select class="address City">
                                                <option value="">市</option>
                                            </select>
                                            <select name='web_sel' class="address Area">
                                                <option value="">区、县</option>
                                            </select>
                                        </div>
                                        <div class="hide_div">
                                            <select class="address virtual_inp">

                                            </select>
                                            <ul class="virtualPeople">

                                            </ul>
                                        </div>
                                        <input class="form-control" style="margin-top: 20px;width: 300px" type="text" placeholder="详细地址" name="area_detail" id="area_detail"><br>
                                        <div class="vip_div">
                                            <label>是否VIP：</label>
                                            <select class="address vip" style="width:80px">
                                                <option value="1">是</option>
                                                <option value="0" selected>否</option>
                                            </select>
                                        </div>
                                        <input class="form-control" style="width: 300px;display:none;" type="text" placeholder="首付比例( 例:0.25 ),默认为:1;即不予赊账" name="first_scale" id="first_scale" value=""><br>
                                        <div class="form-group">
                                            <button type='button' class='btn btn-info ' onclick="getPoint()">获取经纬度
                                            </button>
                                            <input type="hidden" id="point" name="point">
                                            <p class="lng" style="display: none;width:300px;height:30px;line-height:30px;text-indent:20px;float: right;margin-right: 55px;" ></p>
                                        </div>
                                    </div>
                                    <textarea class="form-control describe" placeholder="备注(最长20个字)" maxlength="20" style="width:415px;height:50px;resize:none;"></textarea>
                                    <button type='submit' class='btn btn-success dis' style="margin-left: 400px;margin-top:20px;"
                                            onclick="validateUser()">保存
                                    </button>
                                </div>
                            </div>
                        </div>
                        @include('errors.list')
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=oqyBjKGM57Maq2jDr64qx637kMd1wb4S"></script>
    <script>
        //跳转判断
        function turnPage1() {
            var count=$(".info_sum").text();
            var maxBage=Math.ceil( Number(count)/15 );
            var getPageNum = $('.turnPage1').val();
            if(getPageNum == ""){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text('请输入页码！');
                $(".oSuccess").show(0).delay(1000).hide(0);
            }else if(getPageNum == "0"){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text('请输入正确的页码！');
                $(".oSuccess").show(0).delay(1000).hide(0);
            }else if(getPageNum>maxBage){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text('请输入正确的页码！');
                $(".oSuccess").show(0).delay(1000).hide(0);
            }else if(!/^[0-9]*$/.test(getPageNum)){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text('请输入数字！');
                $(".oSuccess").show(0).delay(1000).hide(0);
            } else {
                if ($.getUrlParam('page') == null) {
                    if(window.location.href.indexOf('&') > 0){
                        window.location.href = window.location.href + "&page=" + parseInt(getPageNum);
                    }else{
                        window.location.href = window.location.href + "?page=" + parseInt(getPageNum);
                    }
                }else{
                    replaceParamVal('page', parseInt(getPageNum));
                }
            }
        }
        /*省市区三级联动*/
        $('.Prov').change(function () {
            $('.City').html("<option value=''>市</option>");
            $('.Area').html("<option value=''>区、县</option>");
        });
        $('.Prov').change(function () {
            var id=$(this).val();
            $('.City').empty();
            $('.City').append("<option value=''>市</option>");
            $('.City').append(getcity(id));
        });
        $('.City').change(function () {
            var id= $(this).val();
            $('.Area').empty();
            $('.Area').append("<option value=''>区、县</option>");
            $('.Area').append( getcity1( id ));
        });
        $(document).on('change','input[type=checkbox]',function () {
            $('#brand_ids').val($('input[name="brand"]:checked').map(function(){return $(this).val()}).get().join(','));
        });
        $('#type').change(function () {
            $('#company_id').val("");
            if($('#type').val()==0){
                $('.brand_box').hide();
            }
            if($('#type').val()==1){
                //要是卖家就不需要填地址信息
                $('.sale_div').hide();
                $('#point').val('{lng: 0, lat: 0}');
            }else {
                $('.sale_div').show();
                $('#brand_ids').val('-1');
            }
        });
        $('#company_id').change(function () {
            $('.brand_box').empty();
            if( $('#company_id').val()!='' && $('#type').val()==1 ){
                $('.brand_box').show();
            }else{
                $('.brand_box').hide();
            }
            var company_id = $('#company_id').val();
            if($('#type').val() == 1 &&$('#company_id').val()!=''){
                $.ajax({
                    headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
                    url:'/backstage/getBrandList',
                    type:'get',
                    data:{'company_id':company_id},
                    dataType:'json',
                    success:function (data) {
                        for(var o in data.info){
                            var check_box= '<label class="checkbox-inline">'+
                                    '<input type="checkbox"  name="brand" class="choose_inp" value="'+o+'">'+data.info[o]+'</label>';
                            $('.brand_box').append(check_box);
                        }
                    }
                })
            }
        });
        $("#first_scale").bind("input","onpropertychange",function(){
            if(parseInt($(this).val())>1){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text("比例不能大于1,请从新输入");
                $(".oSuccess").show(0).delay(1000).hide(0);
                $(this).val('');
            }else if($(this).val()=='0.00'){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text("比例不能为0.00,请从新输入");
                $(".oSuccess").show(0).delay(1000).hide(0);
                $(this).val('');
            }else{
                $(this).val($(this).val().replace(/[^\d.]/g,""));
                $(this).val($(this).val().replace(/\.{2,}/g,"."));

                $(this).val($(this).val().replace(/^\./g,""));

                $(this).val($(this).val().replace(".","$#$").replace(/\./g,"").replace("$#$","."));
                $(this).val($(this).val().replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'));
                if($(this).val().indexOf(".")< 0 && $(this).val() !=""){
                    $(this).val(parseFloat($(this).val()));
                }
            }

        });
        function edit(id) {
            location.href = '/backstage/edit?id='.id
        }
        function moveToBlack(id) {
            $(".oText").text("确定要拉黑吗？");
            $(".oMask").show();
            $(".oAnim").show();
            $(".oBtn0").attr("abc",id);
            $(".oBtn0").attr('id','');
            $(".oBtn0").attr('id','oBlocky');
        }
        /*点确定*/
        $(document).on('click','#oBlocky',function(){
            $(".oMask").hide();
            $(".oAnim").hide();
            var id=$(this).attr("abc");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type: 'post',
                url: '/backstage/toBlack',
                data: {
                    'id': id
                },
                success: function (data) {
                    $(".faceImg").attr("src","/img/laugh.png");
                    $(".oHandle").text("操作成功");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    $('#delete_'+id).remove();
                }
            });
        });
        function getPoint() {
            var area = $('.Prov option:selected' ).text()+$('.City option:selected').text()
                    +$('.Area option:selected').text()+$('#area_detail').val();
            if($("select[name=web_sel]").val() == ''|| $('#area_detail').val() == ''){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text("请选择所在区域和详细地址");
                $(".oSuccess").show(0).delay(1000).hide(0);
                return
            }else {
                //console.log(area);
                var myGeo = new BMap.Geocoder();
                myGeo.getPoint(area, function (point) {
                    //将获取的经纬度传到后台
                    //console.log(point);
                    $('#point').val(JSON.stringify(point));
                    $('.lng').html('东经：'+point.lng+'  北纬：'+point.lat);
                    $('.lng').show();
                }, $('.City option:selected').text());
            }
        }
        //添加用户显示虚拟区
        $(document).on("change",".City",function(){
            if($(".City").val()!="" && $(".company_sel").val()!=""){
                var City=$(".City").val();
                var comp=$(".comp").val();
                $.ajax({
                    headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
                    url:'/company/getCompanyVirtual',
                    type:'post',
                    data:{'company_id':comp,'area_code':City},
                    dataType:'json',
                    success:function (data) {
                        if(data.success){
                            var info1=data.data;
                            var str='<option value="0">请选择虚拟区</option>';
                            if(info1.length<=0){
                                //$(".hide_div").hide();
                                //$(".virtual_inp").val("0");
                                $(".hide_div").show();
                                $(".virtual_inp").empty();
                                $(".virtual_inp").append(str);
                                $(".faceImg").attr("src","/img/weep.png");
                                $(".oHandle").text("暂无虚拟区,请添加虚拟区");
                                $(".oSuccess").show(0).delay(1000).hide(0);
                            }else{
                                $(".hide_div").show();
                                $(".virtual_inp").empty();
                                for(var j=0;j<info1.length;j++){
                                    str+="<option value="+info1[j].id+">"+info1[j].name+"</option>";
                                }
                                $(".virtual_inp").append(str);
                            }
                        }else{
                            $(".faceImg").attr("src","/img/weep.png");
                            $(".oHandle").text(data.msg);
                            $(".oSuccess").show(0).delay(1000).hide(0);
                        }
                    }
                })
            }else{
                $(".hide_div").hide()
            }
        });
        //查看虚拟区人数
        $(document).on("change",".virtual_inp",function(){
            if($(".virtual_inp").val()!="0"){
                var id=$('.virtual_inp').val();
                $.ajax({
                    headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
                    url:'/company/getVirtualUserLists',
                    type:'post',
                    data:{'id':id},
                    dataType:'json',
                    success:function (data) {
                        if(data.success){
                            var infor=data.data;
                            var s='';
                            if(infor.length<=0){
                                $(".virtualPeople").empty();
                            }else{
                                $(".virtualPeople").empty();
                                for(var k=0;k<infor.length;k++){
                                    s+="<li abc="+infor[k].id+">"+infor[k].username+"&nbsp;&nbsp;"+infor[k].area_detail+"</li>";
                                }
                                $(".virtualPeople").append(s);
                            }
                        }else{
                            $(".faceImg").attr("src","/img/weep.png");
                            $(".oHandle").text(data.msg);
                            $(".oSuccess").show(0).delay(1000).hide(0);
                        }
                    }
                })
            }else{
                $(".virtualPeople").empty();
            }
        })
        function validateUser() {
            var brand_ids = $('#brand_ids').val();
            var id = $('#id').val();
            var type = $('#type').val();
            var first_scale = $('#first_scale').val();
            var company_id = $('#company_id').val();
            var Prov = $('.Prov').val();
            var username = $('#username').val();
            var City = $('.City').val();
            var Area = $('.Area').val();
            var area_id=$(".virtual_inp").val();
            var area_detail = $('#area_detail').val();
            var user_tel = $('#user-tel').val();
            var wechat_code=$("#user-vx").val();
            var point = $('#point').val();
            var describe=$(".describe").val();
            var n=0;
            var pass=$(".vip").val();
//            if($(".client").val()==0){//普通客户
//                var pass=$(".vip").val();
//            }
            if($(".client").val()==1){//销售
               pass=0;
            }
            if($('#company_id').val()==''){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text("请选择公司");
                $(".oSuccess").show(0).delay(1000).hide(0);
                return false;
            }
            if($('#type').val()==1){
                for(var i=0; i< $(".choose_inp").length;i++){
                    if($(".choose_inp")[i].checked){
                        n++;
                    }
                }
                if(n<=0){
                    $(".faceImg").attr("src","/img/weep.png");
                    $(".oHandle").text("请选择品牌");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    return false;
                }
            }
            if(first_scale == ''){
                first_scale = 1;
            }
            var reg=/[^\u4E00-\u9FA5]/;
            if(reg.test(username)){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text("请填写中文用户名");
                $(".oSuccess").show(0).delay(1000).hide(0);
                return false;
            }
           if(username == ''){
               $(".faceImg").attr("src","/img/weep.png");
               $(".oHandle").text("用户名不能为空");
               $(".oSuccess").show(0).delay(1000).hide(0);
               return false;
            }else if ($('#user-tel').val() == '') {
               $(".faceImg").attr("src","/img/weep.png");
               $(".oHandle").text("手机号不能为空");
               $(".oSuccess").show(0).delay(1000).hide(0);
                return false;
            }else if (!(/^1[3456789]\d{9}$/.test($('#user-tel').val()))) {
               $(".faceImg").attr("src","/img/weep.png");
               $(".oHandle").text("手机格式不正确");
               $(".oSuccess").show(0).delay(1000).hide(0);
                return false;
            }
            if($('#type').val()==0){
                if($(".Prov").val()==''){
                    $(".faceImg").attr("src","/img/weep.png");
                    $(".oHandle").text("请选择省");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    return false;
                }else if($(".City").val()==''){
                    $(".faceImg").attr("src","/img/weep.png");
                    $(".oHandle").text("请选择市");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    return false;
                }else if($(".Area").val()==''){
                    $(".faceImg").attr("src","/img/weep.png");
                    $(".oHandle").text("请选择区、县");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    return false;
                }else if( $('#area_detail').val()=='' && type == '0') {
                    $(".faceImg").attr("src","/img/weep.png");
                    $(".oHandle").text("请填写详细地址");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    return false;
                }else if( $('#point').val()==''){
                    $(".faceImg").attr("src","/img/weep.png");
                    $(".oHandle").text("请获取经纬度");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    return false;
                }
            }
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type: 'post',
                url: '/backstage/addList',
                dataType:'json',
                data: {
                    'id':id,
                    'type':type,
                    'brand_ids':brand_ids,
                    'first_scale':first_scale,
                    'company_id':company_id,
                    'web_select':Prov,
                    'web_select2':Area,
                    'web_select1':City,
                    'area_detail':area_detail,
                    'user_tel':user_tel,
                    'point':point,
                    'username':username,
                    'area_id':area_id,
                    'describe':describe,
                    'pass':pass,
                    'wechat_code':wechat_code
                },
                success: function (data) {
                    if(data[0].success){
                        $(".faceImg").attr("src","/img/laugh.png");
                        $(".oHandle").text(data[0].msg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                        $(".dis").attr("disabled",true);
                        window.location.href='/backstage';
                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data[0].msg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                        $(".dis").attr("disabled",false);
                    }
                }
            })
        }
        function deleteUser(id) {
            $(".oText").text("确定要删除吗？");
            $(".oMask").show();
            $(".oAnim").show();
            $(".oBtn0").attr("abc",id);
            $(".oBtn0").attr('id','');
            $(".oBtn0").attr('id','oDelete');
        }
        /*点确定*/
        $(document).on('click','#oDelete',function(){
            $(".oMask").hide();
            $(".oAnim").hide();
            var id=$(this).attr("abc");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type: 'post',
                url: '/backstage/delete',
                data: {
                    'id': id
                },
                success: function (data) {
                    $(".faceImg").attr("src","/img/laugh.png");
                    $(".oHandle").text("删除成功");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    $('#delete_'+id).remove();
                }
            });
        });
    </script>
@endsection